/**
 * Author: ZhangYang
 * Version: 1.01
 */

package com.pccw.portlet.util.excel.exportutil;

import com.pccw.portlet.util.excel.ExcelUtil;

public class CellExportRule {
	public static final String CELL_TYPE_OF_HEAD_DATA = "head-data"; // 1.0
	public static final String CELL_TYPE_OF_DETAIL_DATA = "detail-data"; // 1.0
	private static final String[] supportedCellTypes = new String[]{CELL_TYPE_OF_HEAD_DATA, CELL_TYPE_OF_DETAIL_DATA}; // 1.0
	
	public static final String CELL_FORMAT_OF_AUTO = "auto"; // 1.01
	public static final String CELL_FORMAT_OF_GENERAL = "general"; // 1.01
	public static final String CELL_FORMAT_OF_TEXT = "string"; // 1.01
	public static final String CELL_FORMAT_OF_NUMERIC = "numeric"; // 1.01
	public static final String CELL_FORMAT_OF_DATE = "date"; // 1.01
	private static final String[] supportedCellFormats = new String[]{CELL_FORMAT_OF_AUTO, CELL_FORMAT_OF_GENERAL,
		CELL_FORMAT_OF_TEXT, CELL_FORMAT_OF_NUMERIC, CELL_FORMAT_OF_DATE}; // 1.01
	
	private String cellName; // 1.0
	private String cellTitle;
	private int rowId; // 1.0
	private short columnId; // 1.0

	private String beanClass;
	private String beanFieldName;
	private String cellType = CELL_TYPE_OF_HEAD_DATA; // 1.0, head-value/detail-value
	private String validRange = "this"; // 1.0, this/row+n/row+all/column+n/column+all/row-n/row-all/column-n/column-all/all
	private String cellFormat = CELL_FORMAT_OF_AUTO; // 1.01
	
	
	private boolean autoColumnWidth = true; // 1.0

	public CellExportRule(){
	}

	public boolean isAutoColumnWidth() {
		return autoColumnWidth;
	}

	public void setAutoColumnWidth(boolean autoColumnWidth) {
		this.autoColumnWidth = autoColumnWidth;
	}

	public String getBeanFieldName() {
		return beanFieldName;
	}

	public void setBeanFieldName(String beanFieldName) {
		this.beanFieldName = beanFieldName;
	}

	public String getCellType() {
		return cellType;
	}

	public void setCellType(String cellType) {
		this.cellType = cellType;
	}

	public short getColumnId() {
		return columnId;
	}

	public void setColumnId(short columnId) {
		this.columnId = columnId;
	}

	public String getCellName() {
		return cellName;
	}

	public void setCellName(String cellName) {
		this.cellName = cellName;
	}

	public int getRowId() {
		return rowId;
	}

	public void setRowId(int rowId) {
		this.rowId = rowId;
	}

	public String getCellTitle() {
		return cellTitle;
	}

	public void setCellTitle(String cellTitle) {
		this.cellTitle = cellTitle;
	}

	public String getValidRange() {
		return validRange;
	}

	public void setValidRange(String validRange) {
		this.validRange = validRange;
	}
	
	public static boolean isSupportedCellType(String type){
		return ExcelUtil.isValueInOptions(type, supportedCellTypes);
	}
	
	public static boolean isSupportedCellFormat(String type){
		return ExcelUtil.isValueInOptions(type, supportedCellFormats);
	}

	public String getBeanClass() {
		return beanClass;
	}

	public void setBeanClass(String beanClass) {
		this.beanClass = beanClass;
	}
	
	public String getCellFormat() {
		return cellFormat;
	}

	public void setCellFormat(String cellFormat) {
		this.cellFormat = cellFormat;
	}

	public static String[] getSupportedCellTypes() {
		return supportedCellTypes;
	}
	
	public static String[] getSupportedCellFormats() {
		return supportedCellFormats;
	}
	
	public void print(){
		System.out.println("======== Cell Export Rule, begin: ========");
		System.out.println("cellName = " + this.cellName);
		System.out.println("cellTitle = " + this.cellTitle);
		System.out.println("rowId = " + this.rowId);
		System.out.println("columnId = " + this.columnId);
		System.out.println("cellType = " + this.cellType);
		System.out.println("validRange = " + this.validRange);
		System.out.println("======== Cell Export Rule, end. ========");
	}
}
